package com.app.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.app.R;
import com.app.bean.NewsListBean;

import java.util.List;

/**
 * Created by Administrator on 2020/10/12.
 */

public class NewsListAdapter extends BaseAdapter{
    private Context context;
    private List<NewsListBean.ListBean> listBeen;

    public NewsListAdapter(Context context, List<NewsListBean.ListBean> listBeen){
        this.context = context;
        this.listBeen = listBeen;
    }
    @Override
    public int getCount() {
        return listBeen.size();
    }

    @Override
    public Object getItem(int i) {
        return listBeen.get(i);
    }

    @Override
    public long getItemId(int i) {
        return listBeen.get(i).getId();
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        view = View.inflate(context, R.layout.news_list_item_layout,null);
        TextView newsTitle = (TextView)view.findViewById(R.id.news_list_item_title);
        TextView newsDate = (TextView)view.findViewById(R.id.news_list_item_date);
        newsTitle.setText(listBeen.get(i).getTitle()+"");
        newsDate.setText(listBeen.get(i).getDate()+"");
        return view;
    }
}
